package ahut2020.exp06;

//求所有四个自然数p,q,r,s(p<=q<=r<=s)，使得以下等式成立：1/p+1/q+1/r+1/s=1。
public class P05AccumulateFraction {
    public static void main(String[] args) {
        for (int p = 2; p <= 4; p++)
            for (int q = p; q <= 3 * q; q++)
                for (int r = q; r <= 2 * p * q; r++)
                    for (int s = r; s <= p * q * r; s++) {
                        if (p * q * r * s == q * r * s + p * r * s + p * q * s + p * q * r) {
                            System.out.println(String.format("1/%d+1/%d+1/%d+1/%d=1", p, q, r, s));
                        }
                    }
    }
}
